<?php

namespace IDock\Insurance\MACN\Request;

use Exception;
use IDock\Insurance\MACN\Response\ProposalRecallResponse;
use IDock\Visitor\ProposalRecallVisitor;

class ProposalRecallRequest extends AllMACNRequest
{
    protected $requestType = '0014';

    protected $response = ProposalRecallResponse::class;

    protected $urlTip = '投保单撤回';

    /**
     * @var ProposalRecallVisitor $visitor
     */
    protected $visitor;

    public $operatorCode;

    /**
     * @return array
     * @throws Exception
     */
    public function generate(): array
    {
        $arr = [
            'carLogout' => [
                'operatorCode' => $this->visitor->argc['operatorCode'] ?? '',
                'isNormal' => '1',
                'proposalNo' => $this->visitor->biInquiryNo,
                'proposalNo1' => $this->visitor->ciInquiryNo,
                'frameNo' => $this->visitor->argc['frameNo'] ?? '',//车架号
            ],
        ];

        if(empty($arr['carLogout']['proposalNo'])){
            unset($arr['carLogout']['proposalNo']);
        }
        if(empty($arr['carLogout']['proposalNo1'])){
            unset($arr['carLogout']['proposalNo1']);
        }
        return $arr;
    }
}
